package org.client.view.manage;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

import org.client.tools.Mdd;
import org.pojo.MessageType;
import org.pojo.User;
import org.pojo.Message.Message;


public class IMAlterPwClientConServer {
	public Socket sk;
	public boolean sendAlterPwInfoToServer(User request,String passwd) {
		boolean b=false;
		try {
			System.out.println("AlterConnectServer,please wait...");
			sk=new Socket("127.0.0.1",10000);
			ObjectOutputStream oos=new ObjectOutputStream(sk.getOutputStream());
			Message mr= new Message();
			mr.setMesType(MessageType.message_update_password);
			request.setPassword(Mdd.MD5(request.getPassword()));
			mr.setCon(request);
			mr.setChangePasswd(Mdd.MD5(passwd));
			oos.writeObject(mr);
			ObjectInputStream ois=new ObjectInputStream(sk.getInputStream());
			Message msr=(Message)ois.readObject();	
			if(msr.getMesType().equals(MessageType.message_succeed)){
				b = true;
			}
			//关闭Scoket
			oos.close();
			ois.close();
			sk.close();		
		} catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		}			
	return b;
	}
}
